#!/bin/bash

[[ -z ${m0reliance} || ${m0sector} =~ ^# ]] && { exit 0; }
if [[ ${m0type} == "EXTN" ]]; then # exportation
  # cate
  if [[ "$m0tier" == *"+" ]]; then # C++
    fhsty="hh"
    fcsty="cc"
  else # C
    fhsty="h"
    fcsty="c"
  fi
  fHSTY=$(echo "$fhsty" | tr '[:lower:]' '[:upper:]')
  tier0="${m0tier//+}"
  fname="A${m0sector}${m0name}${tier0}${m0version}"
  fNAME=$(echo "$fname" | tr '[:lower:]' '[:upper:]')
  # fade
  fadir="A${m0sector}"
  rm -f ${fadir}/${fname}
  echo "$0: rm -f ${fname} in ${fadir}/"
elif [[ ${m0type} == "ACTN" ]]; then # action
  # cate
  if [[ "$m0tier" == *"+" ]]; then # C++
    fhsty="hh"
    fcsty="cc"
  else # C
    fhsty="h"
    fcsty="c"
  fi
  fHSTY=$(echo "$fhsty" | tr '[:lower:]' '[:upper:]')
  tier0="${m0tier//+}"
  fname="a${m0sector}${m0name}${tier0}${m0version}"
  fNAME=$(echo "$fname" | tr '[:lower:]' '[:upper:]')
  # fade
  fadir="A${m0sector}"; ffdir="F${m0sector}"
  rm -f ${fadir}/${fname}
  rm -f ${fadir}/${fname}.${fcsty}
  rm -f ${fadir}/${fname}.${fhsty}
  rm -f ${ffdir}/${fname}.${fcsty}
  rm -f ${ffdir}/${fname}.${fhsty}
  echo "$0: rm -f ${fname} in ${fadir}/ ${ffdir}/"
else # function
  # cate
  if [[ "$m0tier" == *"+" ]]; then # C++
    fhsty="hh"
    fcsty="cc"
  else # C
    fhsty="h"
    fcsty="c"
  fi
  fHSTY=$(echo "$fhsty" | tr '[:lower:]' '[:upper:]')
  tier0="${m0tier//+}"
  fname="f${m0sector}${m0name}${tier0}${m0version}"
  fNAME=$(echo "$fname" | tr '[:lower:]' '[:upper:]')
  # fade
  ffdir="F${m0sector}"; fsdir="S${m0sector}"; fddir="D${m0sector}"
  rm -f ${ffdir}/${fname}.o
  rm -f ${ffdir}/${fname}.${fcsty}
  rm -f ${ffdir}/${fname}.${fhsty}
  rm -f ${fddir}/lib${fname}.so
  rm -f ${fsdir}/lib${fname}.a
  echo "$0: rm -f ${fname} in ${ffdir}/ ${fddir}/ ${fsdir}/"
fi
